﻿using System.ComponentModel;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using SX.BaseService.API.Base;
using SX.BaseService.Service;
using SX.Core;

namespace SX.BaseService.API
{
   
    [Description("部门管理")]
    [Menu]
    public class SysOrganizeController : BaseController
    {
        private readonly ISysOrganizeService _orgService;
        public SysOrganizeController(ISysOrganizeService sysOrganizeService)
        {
            _orgService = sysOrganizeService;
        }
       
        [HttpGet]
        [Description("查询部门tree")]
        public Task<IApiResult> GetTree()
        {
           return _orgService.GetTree();
        }
        
        [HttpGet]
        [Description("查询")]
        public async Task<IApiResult> Query([FromQuery]OrgQueryModel model)
        {
            return await _orgService.Query(model);
        }
       
        [HttpPost]
        [Description("新增")]
        public async Task<IApiResult> Add([FromBody] OrgAddModel model)
        {
            return await _orgService.Add(model);
        }
       
        [HttpPost]
        [Description("删除")]
        public async Task<IApiResult> Delete([FromBody]string id)
        {
            return await _orgService.Delete(id);
        }
       
        [HttpGet]
        [Description("详情")]
        public async Task<IApiResult> Get([FromQuery] string id)
        {
            return await _orgService.GetById(id);
        }
       
        [HttpPost]
        [Description("更新")]
        public async Task<IApiResult> Update([FromBody] OrgUpdateModel model)
        {
            return await _orgService.Update(model);
        }
    }
}